<?
session_start();
define('_VIEW_MODEL_','default');
require_once './init.php';
$friend = "";
$vid = intval($id);
$id = intval($sid);
$sta = true;
$erro = "";
$tim = time();
$name = array();
if(isset($act)&&$act=="send"){
	$st = $type;
	$val = $msgto;
	$ti  = htmlspecialchars($subject);
	$con = htmlspecialchars($message);
	if($st == "uid"){
		$where = "where id=$val";
	}else{
		$where = "where name=$val";
	}
	$state = $db->GetRow("select id from {$telper}user $where");
	if(!empty($state)){
			//echo "select id,name from {$telper}user where id in($vid,$id)";
			$ns = $db->Execute("select id,name from {$telper}user where id in($vid,$id)");
			$nam = $ns->GetArray();
			foreach($nam as $k=>$v){
				$name[$v['id']] = $v['name'];
			}
			//echo "insert {$telper}mail set `from`='$vid',`fromname`='$name[$vid]',`for`='$id',`forname`='$name[$id]',`title`='$ti',`cont`='$con',`time`='$tim' ";
			$db->Execute("insert {$telper}mail set `from`='$vid',`fromname`='$name[$vid]',`for`='$id',`forname`='$name[$id]',`title`='$ti',`cont`='$con',`time`='$tim' ");
			$erro = "发送成功";
	}else{
		$erro = "用户不存在";
	}
}
$userinfo = $db->GetRow("select a.id,a.name,a.password,a.sex,a.headimage,a.phone,a.money,a.birthday,a.zodiac,a.const,a.tickets,a.likebook,a.onlinetime,a.lasttime,a.activetime,a.sign,a.created,a.isphone,a.state,b.title from {$telper}user as a left join {$telper}prop as b on a.medalid=b.id where a.id = '$id'");
$zomict = $zomictyle[$userinfo['zodiac']]==""?"保密":$zomictyle[$userinfo['zodiac']];
//print_R($userinfo);
$tim  = time();
$rs = $db->Execute("select `title`,`link` from {$telper}friendlink where state = 0 order by rank desc limit 0,6");
$friendinfo = $rs ->GetArray();
foreach($friendinfo as $k=>$v){
	$friend .="<a href='$v[link]'>$v[title]</a>";
	if($k+1 < count($friendinfo)){
		$friend .=".";
	}
}
$colmust = empty($colmustyle[$userinfo['const']])?"保密":$colmustyle[$userinfo['const']];
$age = ceil(($tim - $userinfo['birthday'])/(60*60*24*365));
$age = $userinfo['birthday']=="0"?"保密":$age;
header("Content-type:text/vnd.wap.wml;charset=utf-8");
$smartyObj->assign('userinfo',$userinfo);
$smartyObj->assign('zomicsty',$zomict);
$smartyObj->assign('mon',$userinfo['money']);
$smartyObj->assign("moneyname",$moneyname);
$smartyObj->assign("colmustyle",$colmust);
$smartyObj->assign("friend",$friend);
$smartyObj->assign("uid",$id);
$smartyObj->assign("vid",$vid);
$smartyObj->assign("age",$age);
$smartyObj->assign("time",$tim);
$smartyObj->assign("error",$erro);
$smartyObj->display('orthuser.tpl');
?>